package com.hqyj.lx.controller;


import com.hqyj.lx.pojo.Score;
import com.hqyj.lx.service.ScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class ScoreController {

    @Autowired
    private ScoreService scoreService;

    //查询所有考生成绩
    @RequestMapping("/queryStudentScore")
    public String queryStudentScore(ModelMap modelMap,HttpSession session){


        List<Score> scores = scoreService.queryStudentScore();
        modelMap.put("scores",scores);

        return "scoreList";
    }

    //通过name查询考生成绩
    @RequestMapping("/queryStudentScoreByName")
    public String queryStudentScoreByName(String sName,ModelMap modelMap) {
        List<Score> scores = scoreService.queryStudentScoreByName(sName);
        System.out.println(scores);
        modelMap.put("scores", scores);
        return "scoreList";
    }

    //考生查看自己的成绩
    @RequestMapping("/queryMyScore")
    public String queryMyScore( ModelMap modelMap, HttpSession session){

        List<Score> scores = scoreService.queryMyScore((String)session.getAttribute("sName"));
        System.out.println(scores);
        modelMap.put("scores",scores);

        return "studentScore";
    }
}
